<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>舞林大会</title>
<script type="text/javascript">
	$(function(){
			var acName="上海活动一期";
			var acBeginDate="2016-01-12";
			var acEndDate="2016-02-16";
			$.ajax({
		         type: "POST",
		         url:"<%=basePath%>dance/getActivity",
				 dataType : 'JSON',
				 success : function(result) {
					 var data=result.rows;
					 acName=data.name;
					 acBeginDate=data.beginDate;
					 acEndDate=data.endDate;
					 $("#activity").append("<span>"+acName+"</span>&nbsp;&nbsp;&nbsp;&nbsp;"+"<span>"+acBeginDate+"——</span>"+"<span>"+acEndDate+"</span>");
				 }
			});
			//绑定报名按钮事件
			$("#acApply").click(function(){
				$.ajax({
					type:"POST",
					data:getParams(),
					url : "<%=basePath%>dance/apply",
					success : function(result) {
						if (result.success) {
							$.messager.alert({
								title : 'Success!',
								msg : '成功!',
							});
							//重新加载页面
							reload();

						} else {
							$.messager.alert({
								title : 'Failed!',
								msg : '失败!',
							});
						}
					},
					error : function(result) {
						$.messager.alert({
							title : 'Failed!',
							msg : '添加失败!',
						});
					}

				});
			});
			//刷新当前页面
			function reload(){
				window.location.reload();
			}
			//获得页面数据传递json参数
			function getParams(){
				//操作人
				var operator;
				//队伍id
				var teamId; 
				//队伍编码
				var teamCode;
				//队伍名称
				var teamName;
				//活动id
				var activityId;
				//活动编码
				var activityCode;
				//活动名称
				var activityName;
				//活动第几期主键
				var activityDetailId;
				//活动第几期编码
				var activityDetailCode;
				//活动第几期名称
				var activityDetailName;
				//队伍作品主键
				var teamWorkId;
				//队伍作品名称
				var teamWorkName;
				//队伍作品地址
				var teamWorkLocation;
				//创建人
				var creator;
				//备注
				var remark;
				return{
					"operator":operator,"teamId":teamId,"teamCode":teamCode,"teamName":teamName,"activityId":activityId,
					"activityCode":activityCode,"activityName":activityName,"activityDetailId":activityDetailId,
					"activityDetailCode":activityDetailCode,"activityDetailName":activityDetailName,"teamWorkId":teamWorkId,
					"teamWorkName":teamWorkName,"teamWorkLocation":teamWorkLocation,"creator":creator,"remark":remark
				}
			}	
			
		});
</script>
</head>

<body>
	<div>
    	<div><h2>舞林大会</h2></div>
    	<div id="activity"></div></br>
    	<div>
    		<input type="button" value="报名" disabled="true">
    		<span>————</span>
    		<input type="button" value="分组" disabled="true">
    		<span>————</span>
    		<input type="button" value="比赛" disabled="true">
    		<span>————</span>
    		<input type="button" value="公示" disabled="true">
    	</div></br>
    	<div><span>排名：20</span>&nbsp;&nbsp;&nbsp;&nbsp;<span>投票：3000</span></div>
    	<div id="voteList"><h2>投票列表</h2></div>
    	<div id="acIntroduce"><h2>活动介绍</h2></div>
    	<div><textarea placeholder="活动详情介绍" style="height:200px;width:23%"></textarea></div></br>
    	<input id="acApply" type="button" value="报名">
    </div>
</body>
</html>
